<?php

namespace App\Models\V1;


use Illuminate\Database\Eloquent\Factories\HasFactory;


class Users extends BaseModel
{
    use HasFactory;

    protected $connection;
    protected $table = 'wy_users';
    protected $fillable = [
        'community_id',
        'mobile',
        'real_name',
        'username',
        'partition',
        'building',
        'hnum',
        'floor',
        'integral',
        'avatar',
        'state',
        'preparatory_id',
        'element',
        'remark',
        'area',
    ];

    protected $hidden = [
        'password',
        'token',
    ];


    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        $this->connection = config('database.connections.wuye.database');
    }

    /**
     * 状态
     * @param $key
     * @return string
     */
    public function getStateAttribute($key)
    {
        return (string) $key;
    }




    public function Community()
    {
        return $this->hasOne(Community::class, 'id', 'community_id');
    }

    public function Preparatory()
    {
        return $this->hasOne(Preparatory::class, 'id', 'preparatory_id');
    }












}
